﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinKeyBoard.UcControls
{
    public partial class UcNumKey : UcComonKey
    {
        public UcNumKey()
        {
            InitializeComponent();
        }
        
        

        /// <summary>
        /// 指示灯
        /// </summary>
        public enum LightState
        {
            /// <summary>
            /// 开启
            /// </summary>
            Open,
            /// <summary>
            /// 关闭
            /// </summary>
            Close,
        }
        #region 委托
        
        public delegate void ConStateDelegate(LightState state);
        public ConStateDelegate conStateDelegate;
        #endregion

        

        //初始化
        private void UcNumKey_Load(object sender, EventArgs e)
        {
            IsSelectCon();
        }

        #region 0-9数字
        private void btnNum0_Click(object sender, EventArgs e)
        {
            KeyInput(0);
        }

        private void btnNum1_Click(object sender, EventArgs e)
        {
            KeyInput(1);
        }

        private void btnNum2_Click(object sender, EventArgs e)
        {
            KeyInput(2);
        }

        private void btnNum3_Click(object sender, EventArgs e)
        {
            KeyInput(3);
        }

        private void btnNum4_Click(object sender, EventArgs e)
        {
            KeyInput(4);
        }

        private void btnNum5_Click(object sender, EventArgs e)
        {
            KeyInput(5);
        }

        private void btnNum6_Click(object sender, EventArgs e)
        {
            KeyInput(6);
        }

        private void btnNum7_Click(object sender, EventArgs e)
        {
            KeyInput(7);
        }

        private void btnNum8_Click(object sender, EventArgs e)
        {
            KeyInput(8);
        }

        private void btnNum9_Click(object sender, EventArgs e)
        {
            KeyInput(9);
        }

        #endregion

        #region 加减乘除
        //除号
        private void btnDiv_Click(object sender, EventArgs e)
        {
            KeyInput("{/}");
        }
        //乘号
        private void btnMul_Click(object sender, EventArgs e)
        {
            KeyInput("{*}");
        }
        //减号
        private void btnSub_Click(object sender, EventArgs e)
        {
            KeyInput("{-}");
        }
        //加号
        private void btnAdd_Click(object sender, EventArgs e)
        {
            KeyInput("{+}");
        }
        #endregion

        #region Enter
        //Enter
        private void btnEnter_Click(object sender, EventArgs e)
        {
            KeyInput("{Enter}");
        }
        #endregion

        #region . 键
        private void btnBit_Click(object sender, EventArgs e)
        {
            KeyInput("{.}");
        }
        #endregion

        #region Con 灯键
        private void btnCon_Click(object sender, EventArgs e)
        {
            IsSelectCon();
        }
        private void IsSelectCon()
        {
            btnCon.Selected = !btnCon.Selected;
            if (btnCon.Selected)
            {
                btnCon.TipsColor = Color.Cyan;
                conStateDelegate?.Invoke(LightState.Open);
            }
            else
            {
                btnCon.TipsColor = Color.Silver;
                btnCon.ForeColor = Color.Silver;
                conStateDelegate?.Invoke(LightState.Close);
            }
        }

        #endregion

    }
}
